package cfca.seal.util;

import cfca.sadk.util.Base64;
import cfca.seal.exception.CodeException;
import java.io.PrintStream;

public class EncryptUtil
{
  public static String encrypto(String input)
    throws CodeException
  {
    String ret = input;
    if (StringUtil.isNotEmpty(input)) {
      try {
        ret = new String(Base64.encode(cfca.sadk.util.EncryptUtil.encryptMessageBySM4(input.getBytes(), "1l10OO0O01lll1l1")));
      } catch (Exception ex) {
        throw new CodeException("C3015", "加密字符串失败", ex);
      }
    }
    return ret;
  }

  public static String decrypto(String input)
    throws CodeException
  {
    String ret = input;
    if (StringUtil.isNotEmpty(input)) {
      try {
        byte[] data = Base64.decode(input);
        byte[] endata = cfca.sadk.util.EncryptUtil.decryptMessageBySM4(data, "1l10OO0O01lll1l1");
        ret = new String(endata);
      } catch (Exception ex) {
        throw new CodeException("C3016", "解密字符串失败", ex);
      }
    }
    return ret;
  }

  public static void main(String[] args) throws CodeException {
    System.out.print(decrypto("U1R1VkhWZk55UTU1Q1pqSUFYOEsxUT09"));
  }
}